const constant = require("../../util/constant.js");
const util = require('../../util/util.js');
const app = getApp();
Page({
  data: {
    CustomBar: app.globalData.CustomBar,
    jzlist:[],
    selkey:'',
    userid:''
  },
  copydsr:function(e){
    let dsr=e.currentTarget.dataset["dsr"];
    let dsrhm=e.currentTarget.dataset["dsrhm"];
    let dsrtel=e.currentTarget.dataset["dsrtel"];
    let dsraddr=e.currentTarget.dataset["dsraddress"];
    let isp=e.currentTarget.dataset["isp"];
    wx.redirectTo({
      url: 'anjianedit?dsr='+dsr+'&dsrhm='+dsrhm+'&dsrtel='+dsrtel+'&dsraddr='+dsraddr+'&isp='+isp+'&iscopy=1',
    })
  },
  onLoad:function(option){
    var myuid=wx.getStorageSync('userid');
    //console.log(myuid);
    if(myuid!='')
    {  
        
    }
    else
    {
        wx.redirectTo({
          url: '../login/index',
        })
    }
 
 
    this.setData({
        userid:myuid
    })
      //console.log("ok");
    this.aylist();
  },
  aylist(selkey)
  {
      var uid=this.data.userid;
      var skey=this.data.selkey;
      var that=this;
    wx.request({
        url: constant.host+'/appserv/getmylst.ashx',
        data: {
          uid:uid,
          s:skey,
          k: constant.wkey
        },
        success: function (data) {
          var dat = data.data;
          var pcname=[];
          var cpkey=[];
          var ayindex=0;
          
          for(var i=0;i<dat.length;i++)
          {
            dat[i].isShow=true;
            dat[i].AFDate=util.formatDate(dat[i].AFDate);
            
          }
          
          
          console.log(dat.length);
          that.setData({
            jzlist:dat
          });
        }
      });
  },
  viewaj:function(e){
    let id=e.currentTarget.dataset["ajid"];
    //console.log(id);
    wx.navigateTo({
      url: 'anjianedit?id='+id,
    })
  },
  searchIcon(e) {
    let key = e.detail.value.toLowerCase();
    let list = this.data.jzlist;
    for (let i = 0; i < list.length; i++) {
      let a = key;
      let b = list[i].DSR.toLowerCase();
      let c=list[i].DSRHM;
      let d=list[i].AY;
      let t=list[i].DSRTel;
      if (b.search(a) != -1 ||c.search(a)!=-1 || d.search(a)!=-1 || t.search(a)!=-1) {
        list[i].isShow = true
      } else {
        list[i].isShow = false
      }
    }
    this.setData({
      jzlist: list
    })
  }
})